package com.jy.api.controller.admin;

import com.jy.api.service.NumService;
import com.jy.api.signUpReq.admin.NumReq;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * Created by xiaohua on 2019/2/18.
 */
@Slf4j
@RestController
@RequestMapping(value = "v1/admin/num", produces = "application/json;charset=utf-8")
public class NumController {

    @Autowired
    private NumService numService;

    @GetMapping("all")
    public ResponseEntity getAllNum(@RequestParam("storeId") String storeId, Pageable pageable) {
        return ResponseEntity.ok(numService.getAllNumById(storeId, pageable));
    }

    @PostMapping("add")
    public ResponseEntity addNum(@RequestBody NumReq req) {
        return ResponseEntity.ok(numService.addNumById(req));
    }

    @PostMapping("update")
    public ResponseEntity updateNum(@RequestBody NumReq req) {
        return ResponseEntity.ok(numService.updateNumById(req));
    }

    @PostMapping("delete")
    public ResponseEntity deleteNum(@RequestBody NumReq req) {
        return ResponseEntity.ok(numService.deleteNumById(req));
    }


}
